#include "qwtsliderhost.h"

#include "../../libs/qwt/qwt_slider.h"
#include "../../libs/shared/qhostfactory.h"
#include "../../libs/shared/qpropertyfactory.h"
#include "../../libs/shared/qcommonstruct.h"
#include "../../libs/shared/property/qabstractproperty.h"

QwtSliderHost::QwtSliderHost(QAbstractHost *parent):
    QwtAbstractSliderHost(parent)
{
}

void QwtSliderHost::init_property()
{
    QwtAbstractSliderHost::init_property();

    QAbstractProperty* pro;

    pro=QPropertyFactory::create_property("Enum");
    if(pro!=NULL)
    {
        pro->set_property("name","orientation");
        pro->set_attribute("show_name",tr("Orientation"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);

        ComboItems   items;
        tagComboItem item;

        item.m_text="Horizontal";
        item.m_value=Qt::Horizontal;
        items.append(item);

        item.m_text="Vertical";
        item.m_value=Qt::Vertical;
        items.append(item);

        pro->set_attribute("items",QVariant::fromValue<ComboItems>(items));
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Enum");
    if(pro!=NULL)
    {
        pro->set_property("name","scalePosition");
        pro->set_attribute("show_name",tr("Scale Position"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);

        ComboItems   items;
        tagComboItem item;

        item.m_text="NoScale";
        item.m_value=QwtSlider::NoScale;
        items.append(item);

        item.m_text="LeadingScale";
        item.m_value=QwtSlider::LeadingScale;
        items.append(item);

        item.m_text="TrailingScale";
        item.m_value=QwtSlider::TrailingScale;
        items.append(item);

        pro->set_attribute("items",QVariant::fromValue<ComboItems>(items));
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Bool");
    if(pro!=NULL)
    {
        pro->set_property("name","trough");
        pro->set_attribute("show_name",tr("Trough"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Bool");
    if(pro!=NULL)
    {
        pro->set_property("name","groove");
        pro->set_attribute("show_name",tr("Groove"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Size");
    if(pro!=NULL)
    {
        pro->set_property("name","handleSize");
        pro->set_attribute("show_name",tr("Handle Size"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","borderWidth");
        pro->set_attribute("show_name",tr("Border Width"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","spacing");
        pro->set_attribute("show_name",tr("Spacing"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    set_property_value("geometry",QRect(0,0,50,300));
}

QString QwtSliderHost::get_show_name()
{
    return tr("QWT Slider");
}

QString QwtSliderHost::get_show_group()
{
    return tr("QWT Widgets");
}

QString QwtSliderHost::get_show_icon()
{
    return ":/images/vslider.png";
}

void QwtSliderHost::create_object()
{
    m_object=new QwtSlider;
    m_object->setObjectName("slider");
}

qRegisterHost("qwt.slider",QwtSliderHost,6040)
